﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.ComponentModel;
using NovinMedia.Data;

namespace NovinMedia.Data.Layer
{
    [DataObject(true)]
    public class DM_SU_KIEN
    {
		[DataObjectMethod(DataObjectMethodType.Fill)]
		public DataSet SelectAll()
        {
            DbObject dbo = new DbObject();
            SqlParameter[] parameters = new SqlParameter[]
                {
 
                };
            return dbo.RunProcedure("pr_DM_SU_KIEN_SelectAll", parameters, "DM_SU_KIEN");
        }

		[DataObjectMethod(DataObjectMethodType.Fill)]
		public DataSet SelectRow(float ID)
        {
            DbObject dbo = new DbObject();
            SqlParameter[] parameters = new SqlParameter[]
                {
					new SqlParameter("ID",ID) 
                };
            return dbo.RunProcedure("pr_DM_SU_KIEN_SelectRow", parameters, "DM_SU_KIEN");
        }

		[DataObjectMethod(DataObjectMethodType.Insert)]
		public int InsertRow(float ID_LOAI_SU_KIEN,string TEN_SU_KIEN,DateTime NGAY_DIEN_RA,float ID_TRANG_THAI,string MO_TA)
		{
			int RowsAffected = 0;
			int Result = 0;
			DbObject dbo = new DbObject();
			SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("ID_LOAI_SU_KIEN",ID_LOAI_SU_KIEN),
					new SqlParameter("TEN_SU_KIEN",TEN_SU_KIEN),
					new SqlParameter("NGAY_DIEN_RA",NGAY_DIEN_RA),
					new SqlParameter("ID_TRANG_THAI",ID_TRANG_THAI),
					new SqlParameter("MO_TA",MO_TA) 
				};
			Result = dbo.RunProcedure("pr_DM_SU_KIEN_Insert", parameters, out RowsAffected);
			return Result;
        }

		[DataObjectMethod(DataObjectMethodType.Update)]
		public int UpdateRow(float ID,float ID_LOAI_SU_KIEN,string TEN_SU_KIEN,DateTime NGAY_DIEN_RA,float ID_TRANG_THAI,string MO_TA)
		{
			int RowsAffected = 0;
			int Result = 0;
			DbObject dbo = new DbObject();
			SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("ID",ID),
					new SqlParameter("ID_LOAI_SU_KIEN",ID_LOAI_SU_KIEN),
					new SqlParameter("TEN_SU_KIEN",TEN_SU_KIEN),
					new SqlParameter("NGAY_DIEN_RA",NGAY_DIEN_RA),
					new SqlParameter("ID_TRANG_THAI",ID_TRANG_THAI),
					new SqlParameter("MO_TA",MO_TA) 
				};
			Result = dbo.RunProcedure("pr_DM_SU_KIEN_Update", parameters, out RowsAffected);
			return Result;
        }

		[DataObjectMethod(DataObjectMethodType.Delete)]
		public int DeleteRow(float ID)
		{
			int RowsAffected = 0;
			int Result = 0;
			DbObject dbo = new DbObject();
			SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("ID",ID) 
				};
			Result = dbo.RunProcedure("pr_DM_SU_KIEN_DeleteRow", parameters, out RowsAffected);
			return Result;
        }
    }
}